package cn.getech.data.development.constant;

import lombok.Getter;
import org.apache.commons.lang.StringUtils;


/**
 * @Author luoxi
 * @create 2020/11/20 12:17
 */
@Getter
public enum DataSyncWriteRuleEnum {
    INSERT_OVERWRITE(1,"insert overwrite","overwrite",true),
    INSERT_INTO(2,"insert into","append",false);

    private Integer id;

    private String name;

    private String aliasName;

    private boolean isDefault;



    DataSyncWriteRuleEnum(Integer id,String name,String aliasName,boolean isDefault){
        this.id=id;
        this.name=name;
        this.aliasName=aliasName;
        this.isDefault=isDefault;
    }

    public static String getAliasName(String name){
        if(StringUtils.isBlank(name)){
            return "";
        }
        for (DataSyncWriteRuleEnum value : DataSyncWriteRuleEnum.values()) {
            if(StringUtils.equals(value.getName(),name)){
                return value.getAliasName();
            }
        }
        return "";
    }

    public static String getNameByAliasName(String aliasName){
        if(StringUtils.isBlank(aliasName)){
            return "";
        }
        for (DataSyncWriteRuleEnum value : DataSyncWriteRuleEnum.values()) {
            if(StringUtils.equals(value.getAliasName(),aliasName)){
                return value.getName();
            }
        }
        return "";
    }
}
